package com.example.xunai.dto.response.system;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.Map;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ModelConfigResponse {
    private String defaultModel;
    private Integer totalModels;
    private List<ModelInfo> models;
    private Map<String, Object> configSummary;

    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class ModelInfo {
        private String code;
        private String name;
        private String description;
        private Boolean enabled;
        private Integer maxTokens;
        private Double temperature;
        private Boolean streaming;
        private Boolean configured;
        private Map<String, Object> config;
    }

    public static ModelConfigResponse of(String defaultModel, Integer totalModels,
                                         List<ModelInfo> models, Map<String, Object> configSummary) {
        return ModelConfigResponse.builder()
                .defaultModel(defaultModel)
                .totalModels(totalModels)
                .models(models)
                .configSummary(configSummary)
                .build();
    }

    public static ModelConfigResponse empty() {
        return ModelConfigResponse.builder()
                .defaultModel("deepseek")
                .totalModels(0)
                .models(List.of())
                .configSummary(Map.of())
                .build();
    }
}